package com.example.mongodb.service.impl;

import javax.annotation.Resource;

import org.bson.types.ObjectId;
import org.springframework.stereotype.Service;

import com.example.mongodb.entity.Case;
import com.example.mongodb.repository.CaseRepository;
import com.example.mongodb.service.CaseService;

@Service
public class CaseServiceImpl implements CaseService {

	@Resource
	CaseRepository caseRepository;
	
	@Override
	public Case save(Case cas) {
		return caseRepository.save(cas);
	}

	@Override
	public Case findById(String id) {
		ObjectId oid = new ObjectId(id);
		return caseRepository.findById(oid).orElse(null);
	}

	@Override
	public Case findByCaseNum(String caseNum) {
		return caseRepository.findByCaseNum(caseNum).orElse(null);
	}

	
}
